<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>奥鹏网考系统 - 客户端登录日志</title>
    <link rel="shortcut icon" href="favicon.ico" mce_href="/favicon.ico" type="image/x-icon" />

    <link href="//openexamcdn.open.com.cn/openexam/static/Content/bootstrap.min.css" rel="stylesheet" />
    <link href="//openexamcdn.open.com.cn/openexam/static/App/vendor/jquery.datetimepicker/jquery.datetimepicker.css" rel="stylesheet" />
</head>
<div class="container">
    <div class="page-header">
        <h1>
            奥鹏网考系统 <small>客户端登录日志</small>
        </h1>
    </div>

    <form class="form-inline">
        <div class="form-group">
            <label for="txtExamCardNo">准考证号：</label>
            <input type="text" class="form-control" id="txtExamCardNo" name="examCardNo" placeholder="准考证号" />
        </div>
        <div class="form-group">
            <label for="txtLoginIp">登录IP：</label>
            <input type="text" class="form-control" id="txtLoginIp" name="loginIp" placeholder="登录IP" />
        </div>
        <div class="form-group">
            <label for="txtLoginStatus">登录状态：</label>
            <select class="form-control" id="txtLoginStatus" name="loginStatus" style="max-width: 175px;">
                <option value="">全部状态</option>
                <option value="1">跳转到下载页</option>
                <option value="2">跳转随考列表</option>
                <option value="3">跳转模拟考列表</option>
                <option value="4">今日没有可参加的考试</option>
                <option value="5">考试未开始，禁止登录系统</option>
                <option value="6">考试中途，禁止登录系统</option>
                <option value="7">准考证号无效</option>
                <option value="8">未签到，不能进行考试</option>
                <option value="9">考生号与座位号不符，请确认准考证上的信息！</option>
                <option value="10">已在其他机器上登录</option>
                <option value="11">当前IP不被允许进行考试</option>
            </select>
        </div>
        <br />
        <br />
        <div class="form-group">
            <label for="txtBeginTime">开始时间：</label>
            <div class="input-group">
                <input type="text" class="form-control datetimepicker" id="txtBeginTime" name="beginTime" placeholder="开始时间" readonly="readonly" />
                <span class="input-group-btn">
                        <button type="button" class="btn btn-default btn-sm" onclick="javascript: document.getElementById('txtBeginTime').value = null;">
                            <i class="glyphicon glyphicon-remove"></i>
                        </button>
                    </span>
            </div>
        </div>
        <div class="form-group">
            <label for="txtEndTime">结束时间：</label>
            <div class="input-group">
                <input type="text" class="form-control datetimepicker" id="txtEndTime" name="endTime" placeholder="结束时间" readonly="readonly" />
                <span class="input-group-btn">
                        <button type="button" class="btn btn-default btn-sm" onclick="javascript: document.getElementById('txtEndTime').value = null;">
                            <i class="glyphicon glyphicon-remove"></i>
                        </button>
                    </span>
            </div>
        </div>
        <div class="form-group">
            <label for="txtSessionId">Session ID：</label>
            <input type="text" class="form-control" id="txtSessionId" name="sessionId" placeholder="Session ID" />
        </div>
        <button type="submit" class="btn btn-default">
            <i class="glyphicon glyphicon-search"></i>
            查询
        </button>
    </form>
    <hr />

    <h5>
        总计：<b id="examineeLoginLogCount"></b> 条记录
    </h5>

    <table class="table table-striped table-bordered table-hover" id="examineeLoginLogTable">
        <thead>
        <tr class="success">
            <th class="hidden"></th>
            <th>序号</th>
            <th>主办方ID</th>
            <th>准考证号</th>
            <th>登录IP</th>
            <th>登录状态</th>
            <th>登录时间</th>
            <th>SessionID</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>

<script src="//openexamcdn.open.com.cn/openexam/static/Scripts/jquery-1.12.4.min.js"></script>
<script src="//openexamcdn.open.com.cn/openexam/static/App/vendor/jquery.datetimepicker/jquery.datetimepicker.js"></script>
<script type="text/javascript">
    function GetQueryString(name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    }

    window.onload = function () {
        $('.datetimepicker').datetimepicker({
            lang: 'ch',
            step: 5
        });

        var examCardNo = GetQueryString('examCardNo');
        if (examCardNo)
            document.getElementById('txtExamCardNo').value = examCardNo;

        var loginIp = GetQueryString('loginIp');
        if (loginIp)
            document.getElementById('txtLoginIp').value = loginIp;

        var loginStatus = GetQueryString('loginStatus');
        if (loginStatus)
            document.getElementById('txtLoginStatus').value = loginStatus;

        var beginTime = GetQueryString('beginTime');
        if (beginTime) {
            beginTime = beginTime.replace('+', ' ');
            document.getElementById('txtBeginTime').value = beginTime;
        }

        var endTime = GetQueryString('endTime');
        if (endTime) {
            endTime = endTime.replace('+', ' ');
            document.getElementById('txtEndTime').value = endTime;
        }

        var sessionId = GetQueryString('sessionId');
        if (sessionId)
            document.getElementById('txtSessionId').value = sessionId;

        getExamineeLoginLog(examCardNo,loginIp,loginStatus,beginTime,endTime,sessionId);
    };
    
    function getExamineeLoginLog(examCardNo,loginIp,loginStatus,beginTime,endTime,sessionId) {
        var $table = $("#examineeLoginLogTable");

        $.ajax({
            url:"/Home/ExamineeLoginLog",
            type:"POST",
            dataType:"json",
            data:{
                examCardNo:examCardNo,
                loginIp:loginIp,
                loginStatus:loginStatus,
                beginTime:beginTime,
                endTime:endTime,
                sessionId:sessionId
            },
            success:function (data) {
                var tbody = '';
                if(data.length > 0){
                    for (var i=0;i<data.length;i++){
                        tbody += '<tr>';
                        tbody += '<td class="hidden">'+ data[i].logID +'</td>';
                        tbody += '<td>'+ (i+1) +'</td>';
                        tbody += '<td>'+ data[i].appID +'</td>';
                        tbody += '<td>'+ data[i].loginCode +'</td>';
                        tbody += '<td>'+ data[i].loginIPAddress +'</td>';
                        switch (data[i].loginStatus){
                            case "1":
                                tbody += '<td><span>跳转到下载页</span></td>';
                                break;
                            case "2":
                                tbody += '<td><span>跳转随考列表</span></td>';
                                break;
                            case "3":
                                tbody += '<td><span>跳转模拟考列表</span></td>';
                                break;
                            case "4":
                                tbody += '<td><span>今日没有可参加的考试</span></td>';
                                break;
                            case "5":
                                tbody += '<td><span>考试未开始，禁止登录系统</span></td>';
                                break;
                            case "6":
                                tbody += '<td><span>考试中途，禁止登录系统</span></td>';
                                break;
                            case "7":
                                tbody += '<td><span>准考证号无效</span></td>';
                                break;
                            case "8":
                                tbody += '<td><span>未签到，不能进行考试</span></td>';
                                break;
                            case "9":
                                tbody += '<td><span>考生号与座位号不符，请确认准考证上的信息！</span></td>';
                                break;
                            case "10":
                                tbody += '<td><span>已在其他机器上登录</span></td>';
                                break;
                            case "11":
                                tbody += '<td><span>当前IP不被允许进行考试</span></td>';
                                break;
                            default:
                                tbody += '<td><span>登录失败，请重试！</span></td>';
                                break;
                        }
                        tbody += '<td>'+ data[i].loginTime +'</td>';
                        tbody += '<td>'+ data[i].sessionID +'</td>';
                        tbody += '</tr>';
                    }
                }else{
                    tbody += '<tr> <td colspan="7" style="text-align: center;"> 未查询到数据 </td> </tr>';
                }
                $("#examineeLoginLogCount").html(data.length);
                $table.find("tbody").append(tbody);
            }
        })
    }
</script>
</body>
</html>